#ifndef AFX_DEBUG_H
#define AFX_DEBUG_H

#define SDK_VIRTUAL_TRANS
#undef SDK_VIRTUAL_TRANS

#define DEBUG   4
#define INFO    3
#define WARNING 2
#define ERROR   1

#include "SWITCH.h"

#if (DEBUG_LEVEL >= DEBUG)
#define TraceD(arg...)     DebugTrace("DEBUG", (s8 const*)__FUNCTION__,  __LINE__, ##arg)
#define TraceHexD(pasInfo, pheData, uiLen)   DebugTraceHex("DEBUG", pasInfo, (u8 *)pheData, uiLen, (s8 const*)__FUNCTION__,__LINE__)
#else
#define TraceD(arg...)
#define TraceHexD(pasInfo, pheData, uiLen)
#endif

#if (DEBUG_LEVEL >= INFO)
#define TraceI(arg...)     DebugTrace("INFO", (s8 const*)__FUNCTION__,  __LINE__, ##arg)
#define TraceHexI(pasInfo, pheData, uiLen)   DebugTraceHex("INFO", pasInfo, (u8 *)pheData, uiLen, (s8 const*)__FUNCTION__,__LINE__)
#else
#define TraceI(arg...)
#define TraceHexI(pasInfo, pheData, uiLen)
#endif

#if (DEBUG_LEVEL >= WARNING)
#define TraceW(arg...)     DebugTrace("WARN", (s8 const*)__FUNCTION__,  __LINE__, ##arg)
#define TraceHexW(pasInfo, pheData, uiLen)   DebugTraceHex("WARN", pasInfo, (u8 *)pheData, uiLen, (s8 const*)__FUNCTION__,__LINE__)
#else
#define TraceW(arg...)
#define TraceHexW(pasInfo, pheData, uiLen)
#endif

#if (DEBUG_LEVEL >= ERROR)
#define TraceE(arg...)     DebugTrace("ERROR", (s8 const*)__FUNCTION__,  __LINE__, ##arg)
#define TraceHexE(pasInfo, pheData, uiLen)   DebugTraceHex("ERROR", pasInfo, (u8 *)pheData, uiLen, (s8 const*)__FUNCTION__,__LINE__)
#else
#define TraceE(arg...)
#define TraceHexE(pasInfo, pheData, uiLen)
#endif

#define TrackLog()         sdkDebugTrack(__FUNCTION__,__LINE__)

void DebugTrace(s8 const *pasTag, s8 const *pasFile, int line, char const *pheFmt, ...);

void DebugTraceHex(const s8 *pasTag, s8 *pasInfo, u8 *data, s32 dataLen, s8 const *pasFile, s32 line);

extern void sdkDebugTrack(s8 const *func, u32 line);

extern void sdkDebugOut(s8 *p);

extern s32 sdkDebugGetMemoryInfo(u32 *remainingMemory, u32 *remainingBlock);

extern s32 sdkDebugGetMachineCom(void);

#endif

